#!/usr/bin/env python

import os
from flask_script import Manager, Shell, Server
from flask_migrate import MigrateCommand

from src import create_app
from src.database import db

app = create_app()

manager = Manager(app)


@manager.command
def test():
    """Run the tests."""
    import pytest
    exit_code = pytest.main(['tests', '-q'])
    return exit_code


manager.add_command('server', Server())
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    manager.run()
